﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 原型模式
{
    class Program
    {
        static void Main(string[] args)
        {
            GameSystem gameSystem = new GameSystem();
            gameSystem.Run(new NormalActorA(),new FlyActorB());

            Console.ReadLine();
        }
    }

    public abstract class NormalActor
    {
        public abstract NormalActor clone();
    }

    public class NormalActorA : NormalActor
    {
        public override NormalActor clone()
        {
            Console.WriteLine("NoramlActorA is call");
            return (NormalActor)this.MemberwiseClone(); // 浅复制
        }
    }

    public class NormalActorB : NormalActor
    {
        public override NormalActor clone()
        {
            Console.WriteLine("NormalActorB was called");
            return (NormalActor)this.MemberwiseClone();
        }
    }

    public class GameSystem
    {
        public void Run(NormalActor normalActor,FlyActor flyActor)
        {
            NormalActor normalActor1 = normalActor.clone();
            NormalActor normalActor2 = normalActor.clone();
            NormalActor normalActor3 = normalActor.clone();
            NormalActor normalActor4 = normalActor.clone();
            NormalActor normalActor5 = normalActor.clone();
            FlyActor flyActor1 = flyActor.clone();
            FlyActor flyActor2 = flyActor.clone();
            FlyActor flyActor3 = flyActor.clone();
            FlyActor flyActor4 = flyActor.clone();
            FlyActor flyActor5 = flyActor.clone();
        }
    }

    public abstract class FlyActor
    {
        public abstract FlyActor clone();
    }

    public class FlyActorB : FlyActor
    {
        ///<summary>
        ///浅拷贝，如果用深拷贝，可使用序列化
        ///</summary>
       public override FlyActor clone()
       {
            Console.WriteLine("FlyActorB was called");
            return (FlyActor)this.MemberwiseClone();
       }
        
    }



}
